<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.operations.dataentry.forms.FabDataEntryForm,
                 com.scalar.chiptrack.utils.ConfigManager" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>


<chiptrack:checkLogon sourcePage="/searchPurchaseOrders.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="javascript:poTypeChange()">

<script language="javascript">
function submitPage()
{
	var searchType = document.purchaseOrderSearchForm.searchType.value;
    var PONumber   = document.purchaseOrderSearchForm.poNumber.value;

    if( PONumber != '')
    {
        if( chkSalesOrderNoBegin ( PONumber ) )
        {
            document.purchaseOrderSearchForm.poNumber.focus();
            document.getElementById("errors").innerHTML  = "<br><li>  PO Number should not start with special characters ";
            return false;
        }
        if( chkSalesOrderNo ( PONumber ) == false )
        {
            document.purchaseOrderSearchForm.poNumber.focus();
            document.getElementById("errors").innerHTML  = "<br><li>  Please enter Valid PO Number";
            return false;
        }
    }
	document.purchaseOrderSearchForm.action='<%=chipTracContext%>/searchPurchaseOrders.do?action='+ searchType+'&search=true';
    //document.purchaseOrderSearchForm.submit();
    return true;
}

function modify( purchaseOrder_id, purchaseOrder_Type )
{
	var searchType = document.purchaseOrderSearchForm.searchType.value;
	if( purchaseOrder_Type == 1 )
	{
		if( ( "searchViewPurchaseOrder" ==  searchType ) )
		{
			document.purchaseOrderSearchForm.action='<%=chipTracContext%>/openPurchaseOrder.do?action=view&purchaseOrder_id='+ purchaseOrder_id;
		}
		else if( ( "searchCancelledPurchaseOrder" ==  searchType ) )
		{
			document.purchaseOrderSearchForm.action='<%=chipTracContext%>/openPurchaseOrder.do?action=view&purchaseOrder_id='+ purchaseOrder_id;
		}
		else if( ( "searchPendingPurchaseOrder" ==  searchType ) )
		{
			document.purchaseOrderSearchForm.action='<%=chipTracContext%>/openPurchaseOrder.do?action=update&purchaseOrder_id='+ purchaseOrder_id+'&path='+searchType ;
		}
		else
		{
			document.purchaseOrderSearchForm.action='<%=chipTracContext%>/openPurchaseOrder.do?action=update&purchaseOrder_id='+ purchaseOrder_id+'&path='+searchType ;
		}
	}
	else
	{
        document.purchaseOrderSearchForm.action='<%=chipTracContext%>/purchaseOrders.do?action=load&purchaseOrder_Id=' + purchaseOrder_id;
	}

    document.purchaseOrderSearchForm.submit();
}

function showPoForViewPrint( purchaseOrderId)
{
    var poViewURL = '<%=chipTracContext%>/openPurchaseOrder.do?action=printerFriendly&purchaseOrderId='+ purchaseOrderId;
    newWindow = window.open (poViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
    newWindow.focus();
}


function showStaPoForViewPrint( purchaseOrderId, vendorId)
{
    var poViewURL = '<%=chipTracContext%>/purchaseOrders.do?action=printerFriendly&purchaseOrderId='+ purchaseOrderId+'&vendorId='+ vendorId;
    newWindow = window.open (poViewURL,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
    newWindow.focus();
}
function poTypeChange()
{
	if ( document.purchaseOrderSearchForm.poType.value == '1' )
	{
		document.purchaseOrderSearchForm.processStep_Id.value			= -1;
        document.purchaseOrderSearchForm.processStep_Id.disabled		= true;
	}
	else
	{
		document.purchaseOrderSearchForm.processStep_Id.disabled = false;
	}
}
</script>

<!-- Top Header Start-->

<%@ include file="/jsp/includes/header.jsp" %>

<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY >
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@include file="/jsp/finance/purchase_order_menu.jsp" %>

<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
<html:form name="purchaseOrderSearchForm" type="com.scalar.chiptrack.finance.openpo.forms.PurchaseOrderSearchForm" action="/searchPurchaseOrders" onsubmit="javascript:return submitPage()">
    <table border="0" align = "left" width ="100%" >
		<%
			String searchType = "";
			searchType = (String)request.getAttribute( "action" );
			if( searchType == null )
			{
				searchType = request.getParameter( "action" );
			}
		%>
		<input type="hidden" name="searchType" value="<%=searchType%>">
		<tr><td colspan="5">&nbsp;&nbsp;</td></tr>
		<tr><td colspan="5" align="center" valign="center"><font class="NArialW">
		<%
			if( searchType != null && "searchChangePurchaseOrder".equalsIgnoreCase( searchType ) )
			{
		%>
			Change Purchase Order Search
		<%
			}
			else if ( searchType != null && "searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) )
			{
		%>
			Pending Purchase Order Search
		<%
			}
			else if ( searchType != null && "searchViewPurchaseOrder".equalsIgnoreCase( searchType ) )
			{
		%>
			View Purchase Order Search
		<%
			}
			else if ( searchType != null && "searchCancelledPurchaseOrder".equalsIgnoreCase( searchType ) )
			{
		%>
			Cancelled Purchase Order Search
		<%
			}
		%>

		</font></td></tr>
        <tr><td colspan="5"><IMG height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
        <tr><td colspan=5 class="NArialL" align="left"><font color="FF0000"><FONT id="errors"></FONT></font></td></tr>
		<tr><td colspan=5><chiptrack:errors styleClass="NArialL"/></td></tr>
		<tr><td colspan=5><chiptrack:info styleClass="NArialL"/></td></tr>
        <tr><td colspan="5"><IMG height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
        <tr>
            <td>&nbsp;</td>
            <td ><font class = "NArialL">PO Number</font></td>
            <td>
				<html:text name="purchaseOrderSearchForm" property="poNumber" styleClass='txfield' maxlength="50" />
            </td>
            <td><font class = "NArialL">Vendor Name </font></td>
            <td>
                <html:select name="purchaseOrderSearchForm" property="vendor_id" styleClass="txfield">
                    <option value="-1">--Select Vendor-- </option>
                    <html:options collection = "vendorsList" property="value" labelProperty="label"/>
                </html:select>
            </td>
        </tr>
        <tr><td colspan="5"><IMG height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
         <tr>
            <td>&nbsp;</td>
            <td ><font class = "NArialL">PO Type</font></td>
            <td>
				<html:select name="purchaseOrderSearchForm" property="poType" styleClass="txfield" onchange="poTypeChange()">
					<option value="-1">--Select PO Type-- </option>
					<html:options collection = "purchaseOrderTypesList" property="label" labelProperty="value"/>
				</html:select>
            </td>
			<%
			if( searchType != null && !"searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) && !"searchCancelledPurchaseOrder".equalsIgnoreCase( searchType ) )
			{
			%>
            <td><font class = "NArialL">Status </font></td>
            <td>
				<html:select name="purchaseOrderSearchForm" property="status" styleClass="txfield">
					<option value="-1">--Select Status-- </option>
					<html:options collection = "purchaseOrderStatusList" property="label" labelProperty="value"/>
				</html:select>
            </td>
			<%
			}
			else
			{
			%>
			<td colspan="2"></td>
			<%
			}
			%>
        </tr>
        <tr><td colspan="5"><IMG height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
        <tr>
            <td>&nbsp;</td>
            <td ><font class = "NArialL">Part Number</font></td>
            <td>
				<html:select name="purchaseOrderSearchForm" property="processStep_Id" styleClass="txfield">
					<option value="-1">--Select Part Number-- </option>
					<html:options collection = "productList" property="value" labelProperty="label"/>
				</html:select>
            </td>
            <td><font class = "NArialL">Year </font></td>
            <td>
				<html:select name="purchaseOrderSearchForm" property="year" styleClass="txfield">
					<option value="-1">-- All -- </option>
					<html:options collection="yearList" property="label" labelProperty="value"/>
				</html:select>
            </td>
        </tr>
        <tr><td colspan="5"><IMG height=20 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
        <tr>
            <TR align = "center" border="0">
            <TD  bgColor= "" align="center" colspan = '5'>
                <%-- <A href="javascript:submit();" ><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Create PO';return true" onmouseout="window.status='';return true" title="Click here to Create PO"></A>&nbsp;&nbsp;&nbsp;--%>
                <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click here to Search Purchase Order Details';return true" onmouseout="window.status='';return true" title="Click here to Search for Purchase Orders"/>&nbsp;&nbsp;&nbsp;
                <A href="javascript:document.purchaseOrderSearchForm.reset();poTypeChange()" onMouseOver="window.status='Click to Reset the PO Information';return true" onMouseOut="window.status='';return true" title="Click here to Reset Process Information"><IMG border=0 src="<%=chipTracContext%>/jsp/includes/images/reset.gif"></a>
            </TD>
         </TR>
        </tr>
        <tr><td>&nbsp;&nbsp;</td></tr>
        <tr>
            <td colspan = '5' align = "center">
				<logic:notEmpty name="purchaseOrderSearchForm" property="purchaseOrderSearchList" >
                <table border = "0"  width = "100%" align = "center" id = "dp">
					<tr bgcolor="#993333">
						<td align="center"><font class = "NArialL"><font color = "#FFFFFF">PO Number</font></font></td>
						<td align="center"><font class = "NArialL"><font color = "#FFFFFF">Vendor Name</font></font></td>
						<td align="center"><font class = "NArialL"><font color = "#FFFFFF">PO Date</font></font></td>
						<td align="center"><font class = "NArialL"><font color = "#FFFFFF">Status</font></font></td>
						<td align="center"><font class = "NArialL"><font color = "#FFFFFF">PO Type</font></font></td>
						<td align="center"><font class = "NArialL"><font color = "#FFFFFF">Action</font></font></td>
					</tr>
					<tr  class="txfield" >
					</tr>
					<logic:iterate id="purchaseOrder" name="purchaseOrderSearchForm" property="purchaseOrderSearchList" indexId="iteratorIdx" type="com.scalar.chiptrack.finance.openpo.PurchaseOrder">
					<tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%> >
						<td width="15%" align="center">
							<font class="NArialL"><bean:write name="purchaseOrder" property="purchaseOrderNumber"/></font>
						</td>
						<td width="17%" align="center">
							<font class="NArialL"><bean:write name="purchaseOrder" property="vendorName" /></font>
						</td>
                        <td width="17%" align="center">
							<font class="NArialL"><bean:write name="purchaseOrder" property="purchaseOrderDate"/></font>
						</td>
                        <td width="17%" align="center">
							<font class="NArialL"><bean:write name="purchaseOrder" property="status"/></font>
						</td>
                        <td width="17%" align="center">
							<font class="NArialL"><bean:write name="purchaseOrder" property="POTypeString" /></font>
						</td>
						<td width="17%" align="center"><font class="NArialL">
						<a href="javascript:modify(<bean:write name="purchaseOrder" property="purchaseOrder_Id"/>, <bean:write name="purchaseOrder" property="purchaseOrderType"/>);" onmouseover="window.status='Click to Modify Process Details';return true" onmouseout="window.status='';return true">
						<%
							if( searchType != null && "searchChangePurchaseOrder".equalsIgnoreCase( searchType ) )
							{
						%>
							Edit
						<%
							}
							else if ( searchType != null && "searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) )
							{
						%>
							Approve
						<%
							}
							else if ( searchType != null && "searchViewPurchaseOrder".equalsIgnoreCase( searchType ) )
							{
						%>
							View
						<%
							}
							else if ( searchType != null && "searchCancelledPurchaseOrder".equalsIgnoreCase( searchType ) )
							{
						%>
							View
						<%
							}
						%>
						</a>
						</td>
					</tr>
					</logic:iterate>
				</table>
				</logic:notEmpty>
            </td>
        </tr>
     </table>

</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
